/*
 * @Author: your name
 * @Date: 2021-10-21 13:10:56
 * @LastEditTime: 2021-12-17 18:51:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jingfeng-web\src\store\modules\situation.js
 */
import { OverView } from '@/api/overView/service'
const state = {
    // 确定弹出框是否弹出
    showState: false,
    // 点击的是否是左边菜单栏或者左上角退出按钮
    showItem: false,
    accountId: '', // 登录人id
    // 跳转路径
    toPath: '',
    feedbackFilter: {
        feedback_status: 1,
        serverRequestTag: '',
        c2Status: '',
        marketProjectStatusId: '', // 营销项目名称
        marketProjectNameId: '', // 营销项目状态名称
        problemTypeParentId: '', // 问题类型
        problemTypeId: '',
        feedBackSourceId: '', // 反馈来源
        ctag: '',
        c1StatusId: '', // 默认C1已关闭
        productId: [''],
        closeTheReason: '',
        content: '',
        InfluenceCategoryId: '',
        stageId: '',
        assignedUserId: '',
        creatorId: '',
        feedback_number: '',
        dateTime: [],
        versionNumber: '',
        startTime: '',
        endTime: '',
        linkType: ''
    },
    taskFllter: {
        taskStatus: 1,
        t__ctag: '', // 状态标识
        f__product_id: [''], // 所属产品
        t__responsible_user: '', // 责任人
        t__created_at: [], // 创建时间
        t__task_number: '', // 任务ID
        // t__c2_status: '', // C2状态
        ps__id: '', // C1状态
        startTime: '',
        endTime: ''
    },
    sponsorFllter: {
        feedback_status: '',
        serverRequestTag: '',
        c2Status: '',
        marketProjectStatusId: '', // 营销项目名称
        marketProjectNameId: '', // 营销项目状态名称
        problemTypeParentId: '', // 问题类型
        problemTypeId: '',
        feedBackSourceId: '', // 反馈来源
        ctag: '',
        c1StatusId: '', // 默认C1已关闭
        productId: [''],
        closeTheReason: '',
        content: '',
        InfluenceCategoryId: '',
        stageId: '',
        assignedUserId: '',
        creatorId: '',
        feedback_number: '',
        dateTime: [],
        versionNumber: '',
        startTime: '',
        endTime: ''
    },
    feenbackpaneFllter: {
        serverRequestTag: '',
        marketProjectStatusId: '', // 营销项目名称
        marketProjectNameId: '', // 营销项目状态名称
        problemTypeParentId: '', // 问题类型
        problemTypeId: '',
        feedBackSourceId: '', // 反馈来源
        ctag: '',
        productId: [''],
        closeTheReason: '',
        content: '',
        title: '',
        c2Status: '',
        c1StatusId: '',
        InfluenceCategoryId: '',
        stageId: '',
        assignedUserId: '',
        versionNumber: '',
        creatorId: '',
        feedback_number: '',
        dateTime: [],
        startTime: '',
        endTime: '',
        // feedback_status: 0,
        operation_status: 2
    },
    taskpaneFllter: {
        t__ctag: '', // 状态标识
        f__product_id: [''], // 所属产品
        t__responsible_user: '', // 责任人
        t__created_at: [], // 创建时间
        t__task_number: '', // 任务ID
        ps__id: '', // C1状态
        dateTime: [],
        startTime: '',
        endTime: ''
    },
    connectText: ''
}
const mutations = {
    SET_SHOW_STATE(state, value) {
        state.showState = value
    },
    SET_SHOW_ITEM(state, value) {
        state.showItem = value
    },
    SET_ACCOUNT_ID(state, value) {
        state.accountId = value
    },
    SET_TO_PATH(state, value) {
        state.toPath = value
    },
    SET_FEEDBACK_FILTER(state, value) {
        state.feedbackFilter = value
    },
    SET_TASK_FILTER(state, value) {
        state.taskFllter = value
    },
    SET_SPONSOR_FILTER(state, value) {
        state.sponsorFllter = value
    },
    SET_FEEDBACKPANE_FILTER(state, value) {
        state.feenbackpaneFllter = value
    },
    SET_TASKPANE_FILTER(state, value) {
        state.taskpaneFllter = value
    },
    SET_COMMENT_TEXT(state, value) {
        state.connectText = value
    }

}
const actions = {
    setShowState({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_SHOW_STATE', val)
            resolve(val)
        })
    },
    setShowItem({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_SHOW_ITEM', val)
            resolve(val)
        })
    },
    setAccountId({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_ACCOUNT_ID', val)
            resolve(val)
        })
    },
    setFeedbackFilter({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_FEEDBACK_FILTER', val)
            resolve(val)
        })
    },
    setToPath({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_TO_PATH', val)
            resolve(val)
        })
    },
    setTaskFilter({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_TASK_FILTER', val)
            resolve(val)
        })
    },
    setSponsorFilter({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_SPONSOR_FILTER', val)
            resolve(val)
        })
    },
    setFeedbackpaneFilter({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_FEEDBACKPANE_FILTER', val)
            resolve(val)
        })
    },
    setTaskpaneFilter({ commit }, val) {
        return new Promise(resolve => {
            commit('SET_TASKPANE_FILTER', val)
            resolve(val)
        })
    },
    async setCommentText({ commit }, val) {
        try {
            const result = await OverView.GetAllAnnouncementListAsync()
            if (result.success) {
                this.messageOutput = result.data
                if (this.messageOutput.length > 0) {
                    return new Promise(resolve => {
                        commit('SET_COMMENT_TEXT', this.messageOutput[0].announcementContent)
                        resolve(val)
                    })
                }
            }
        } catch (err) {
            console.log(err)
        }
    }
}
export default {
    namespaced: true,
    state,
    actions,
    mutations
}
